<template>
  <div>
    <TableSearch
      ref="tableSearch"
      :tableBtns="tableBtns"
      :search-path="searchPath"
      :formItemsInline="formItemsInline"
      :columns="columns"
      :tableData="tableData"
      :form="form"
      @handleTableData="handleTableData"
      @reset="reset"
    >
    </TableSearch>
  </div>
</template>
<script>
import TableSearch from '@/components/TableSearch'
import { splitBillList } from '@/api/user'
export default {
  name: 'StaffList',
  components: { TableSearch },
  mounted() {},
  data() {
    return {
      loading: false,
      addDlgVisible: false,
      staffRoles: [],
      dlgTitle: '添加用户',
      dlgType: 'add',
      selectStaff: {},
      columns: [
        {
          label: '分账人名称',
          prop: 'partnerName',
        },
        {
          label: '分账订单号',
          prop: 'splitOrderNum',
          // resourceId: '/web/user-management/staff-management/代理商名称',
        },
        {
          label: '支付记录订单号',
          prop: 'paymentBillNum',
          // resourceId: '/web/user-management/staff-management/代理商名称',
          width: 140,
        },
        {
          label: '分账记录订单号',
          prop: 'payServerOrderId',
          width: 140,
        },
        {
          label: '平台分账比例',
          prop: 'platformProportion',
          formatter: (data) => {
            return data.platformProportion + '%'
          },
        },
        {
          label: '平台分账金额',
          prop: 'platformAmount',
        },
        {
          label: '运营商名称',
          prop: 'merchantName',
        },
        {
          label: '运营商分账比例',
          prop: 'merchantProportion',
          formatter: (data) => {
            return data.merchantProportion + '%'
          },
        },
        {
          label: '运营商分账金额',
          prop: 'merchantAmount',
        },
        {
          label: '分账人分账比例',
          prop: 'partnerProportion',
          formatter: (data) => {
            return data.partnerProportion + '%'
          },
        },
        {
          label: '分账人分账金额',
          prop: 'partnerAmount',
        },
      ],
      tableData: {},
      form: {},
      tableBtns: [],
      searchPath: '/web/user-management/staff-management/查询',
      formItemsInline: [
        {
          type: 'text',
          value: 'merchantName',
          placeholder: '运营商名称',
          clearable: true,
          resourceId: '/web/user-management/staff-management/姓名',
        },
        {
          type: 'text',
          value: 'partnerName',
          placeholder: '分账人名称',
          clearable: true,
          resourceId: '/web/user-management/staff-management/姓名',
        },
        {
          type: 'select',
          value: 'splitType',
          placeholder: '分账类型',
          clearable: true,
          options: [
            { label: '支付宝', value: 'ALIPA_SPLIT' },
            { label: '不分账', value: 'NOT_SPLIT' },
            { label: '微信', value: 'WECHAT_SPLIT' },
          ],
          resourceId: '/web/user-management/staff-management/姓名',
        },
        {
          type: 'select',
          value: 'splitStatus',
          placeholder: '分账状态',
          clearable: true,
          options: [
            { label: '完成', value: 'FINISHED' },
            { label: '失败', value: 'FAIL' },
          ],
          resourceId: '/web/user-management/staff-management/姓名',
        },
      ],
    }
  },
  methods: {
    reset() {
      this.form = {}
    },
    refresh() {
      this.$refs.tableSearch.refreshTable()
    },
    handleTableData(params) {
      splitBillList(params).then((res) => {
        this.tableData = {
          list: res.list,
          totalCount: res.totalAmount,
        }
      })
    },
  },
}
</script>
